package com.example.yls.demoa;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btn1;
    private Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn1=findViewById(R.id.btn_1);
        btn2=findViewById(R.id.btn_2);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //第一种
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,
                        ActivityB.class);
                startActivity(intent);

                //第二种 支持跨应用调用 exported
               /* Intent intent2 = new Intent();
                intent2.setClassName("com.example.yls.demoa",
                        "com.example.yls.demoa.ActivityB");
                startActivity(intent2);*/
                //第二种
               /* Intent intent3 = new Intent();
                intent3.setClassName(MainActivity.this,
                        "com.example.yls.demoa.ActivityB");
                startActivity(intent3);*/
            }
        });

        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                /*intent.setAction(intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.baidu.com"));
               */
                //跳转到ActivityB
               /*intent.setAction("open_activityB");*/
                intent.setAction("i_want_eat");
                intent.setAction("ji_pa_fan");
                startActivity(intent);









            }
        });
    }
}
